package com.hhm.huo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hhm.huo.entity.Authority;
import com.hhm.huo.entity.User;
import com.hhm.huo.mapper.AuthorityMapper;
import com.hhm.huo.mapper.UserMapper;
import com.hhm.huo.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 安安
 * @since 2022-05-26
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
    /*@Autowired
    UserMapper userMapper;
    @Autowired
    AuthorityMapper authorityMapper;
    @Override
    public User getByName(String username) {
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq("username",username);
        //获取用户的信息
        User loginUser = userMapper.selectOne(wrapper);
        loginUser.setAdmin(0);
        QueryWrapper<Authority> wrapper1 = new QueryWrapper<>();
        wrapper1.eq("username",username);
        List<Authority> authorities = authorityMapper.selectList(wrapper1);
        for (Authority authority : authorities) {
            if ("ADMIN".equals(authority.getAuthority())){
                loginUser.setAdmin(1);//管理员
            }
        }
        loginUser.setAuthorityList(authorities);
        return loginUser;
    }*/
}
